﻿<script src="~/Scripts/jquery-easyui-extensions/treegrid/jeasyui.extensions.treegrid.checkPosition.js"></script>
<div class="easyui-panel" data-options="fit:true,border:false">
    <table id="tg1"></table>
</div>


<script>
    $(function () {
        var getFrozenColumns = function () {
            var result = [];

            var c1 = [];
            c1.push({ field: 'AreaName', title: '地区', width: 150 });
            c1.push({ field: 'ID', title: '主键', width: 100 });
            c1.push({ field: 'Sex1', title: '男', width: 90 });
            c1.push({ field: 'Sex2', title: '女', width: 90 });

            result.push(c1);

            return result;
        };

        var getColumns = function () {
            var result = [];

            var normal = [
                { field: 'TS1', title: '测试1', width: 60 },
                { field: 'TS2', title: '测试2', width: 60 }
            ];
            result.push(normal);

            return result;
        };
        var options = {
            title: "列表",
            idField: "ID",
            treeField: "AreaName",
            rownumbers: true,
            fit: true,
            border: false,
            singleSelect: true,
            toolbar: [
                {
                    iconCls: 'icon-add',
                    text: "检查[南京]是否是 root 节点",
                    handler: function () {
                        var ret = $("#tg1").treegrid("isRoot", 3);
                        $.messager.alert("数据返回", "[南京] " + (ret ? "是" : "不是") + " root 节点。");
                    }
                },
                {
                    iconCls: 'icon-add',
                    text: "检查[奉化]是否是 root 节点",
                    handler: function () {
                        var ret = $("#tg1").treegrid("isRoot", 1011);
                        $.messager.alert("数据返回", "[奉化] " + (ret ? "是" : "不是") + " root 节点。");
                    }
                },
                "-",
                {
                    iconCls: 'icon-add',
                    text: "检查[杭州]是否是[西湖区]的 parent 节点",
                    handler: function () {
                        var ret = $("#tg1").treegrid("isParent", { id1: 100, id2: 1001 });
                        $.messager.alert("数据返回", "[杭州] " + (ret ? "是" : "不是") + " [西湖区]的 parent 节点。");
                    }
                },
                {
                    iconCls: 'icon-add',
                    text: "检查[温州]是否是[浙江]的 child 节点",
                    handler: function () {
                        var ret = $("#tg1").treegrid("isChild", { id1: 102, id2: 1 });
                        $.messager.alert("数据返回", "[温州] " + (ret ? "是" : "不是") + " [浙江]的 child 节点。");
                    }
                },
                "-",
                {
                    iconCls: 'icon-add',
                    text: "检查[深圳]和[湖州]是否是平级节点",
                    handler: function () {
                        var ret = $("#tg1").treegrid("isSibling", { id1: 6, id2: 103 });
                        $.messager.alert("数据返回", "[深圳]和[湖州] " + (ret ? "是" : "不是") + " 平级节点。");
                    }
                }
            ],
            frozenColumns: getFrozenColumns(),
            columns: getColumns(),
            method: "get",
            url: "/Jsons/treegrid/treegrid-common-data.json"
        };

        $("#tg1").treegrid(options);
    });
</script>